﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WF.DAL;

namespace WF.Model
{
    /// <summary>
    /// EmployeeEntity实体对象
    /// </summary>
    [Serializable]
    public class EmployeeEntity : EntityBase<Employee>
    {

        #region 构造函数

        public EmployeeEntity()
            : base()
        {
            SyncTime = DateTime.Now;
        }
        public EmployeeEntity(Employee obj)
            : base(obj)
        {
            SyncTime = DateTime.Now;
        }
        #endregion

        #region 实现基类abstract属性

        public override string ID
        {
            get
            {
                return DbEntity.EmpID;
            }
            set
            {
                DbEntity.EmpID = value; this.SendPropertyChanged("EmpID");
            }
        }

        public override string DisplayName
        {
            get { return DbEntity.EmpName; }
        }

        #endregion

        #region region Public 属性

        public string Name
        {
            get
            {
                return DbEntity.EmpName;
            }
            set
            {
                DbEntity.EmpName = value; this.SendPropertyChanged("EmpName");
            }
        }

        public string EmpNo
        {
            get
            {
                return DbEntity.EmpNo;
            }
            set
            {
                DbEntity.EmpNo = value; this.SendPropertyChanged("EmpNo");
            }
        }

        public string IDCard
        {
            get
            {
                return DbEntity.IDCard;
            }
            set
            {
                DbEntity.IDCard = value; this.SendPropertyChanged("IDCard");
            }
        }

        public string EmpNameEN
        {
            get
            {
                return DbEntity.EmpNameEN;
            }
            set
            {
                DbEntity.EmpNameEN = value; this.SendPropertyChanged("EmpNameEN");
            }
        }

        public string Sex
        {
            get
            {
                return DbEntity.Sex;
            }
            set
            {
                DbEntity.Sex = value; this.SendPropertyChanged("Sex");
            }
        }

        public string Email
        {
            get
            {
                return DbEntity.Email;
            }
            set
            {
                DbEntity.Email = value; this.SendPropertyChanged("Email");
            }
        }

        public string DomainAccount
        {
            get
            {
                return DbEntity.DomainAccount;
            }
            set
            {
                DbEntity.DomainAccount = value; this.SendPropertyChanged("DomainAccount");
            }
        }

        public string JobLevel
        {
            get
            {
                return DbEntity.JobLevel;
            }
            set
            {
                DbEntity.JobLevel = value; this.SendPropertyChanged("JobLevel");
            }
        }

        public string JobGrade
        {
            get
            {
                return DbEntity.JobGrade;
            }
            set
            {
                DbEntity.JobGrade = value; this.SendPropertyChanged("JobGrade");
            }
        }

        public string Mobile
        {
            get
            {
                return DbEntity.Mobile;
            }
            set
            {
                DbEntity.Mobile = value; this.SendPropertyChanged("Mobile");
            }
        }

        public string DateBirth
        {
            get
            {
                return DbEntity.DateBirth;
            }
            set
            {
                DbEntity.DateBirth = value; this.SendPropertyChanged("DateBirth");
            }
        }

        public System.DateTime? InGroupDate
        {
            get
            {
                return DbEntity.InGroupDate;
            }
            set
            {
                DbEntity.InGroupDate = DateTime.MinValue == value ? null : value;
                this.SendPropertyChanged("InGroupDate");
            }
        }

        public System.DateTime? InCompanyDate
        {
            get
            {
                return DbEntity.InCompanyDate;
            }
            set
            {
                DbEntity.InCompanyDate = DateTime.MinValue == value ? null : value;
                if (value != null && value < new DateTime(1899, 1, 1, 0, 0, 0))
                {
                    DbEntity.InCompanyDate = new DateTime(1899, 1, 1, 0, 0, 0);
                }
                this.SendPropertyChanged("InCompanyDate");
            }
        }

        public System.DateTime? InDeptDate
        {
            get
            {
                return DbEntity.InDeptDate;
            }
            set
            {
                DbEntity.InDeptDate = DateTime.MinValue == value ? null : value;
                if (value != null && value < new DateTime(1899, 1, 1, 0, 0, 0))
                {
                    DbEntity.InDeptDate = new DateTime(1899, 1, 1, 0, 0, 0);
                }
                this.SendPropertyChanged("InDeptDate");
            }
        }

        public System.DateTime? InDueDate
        {
            get
            {
                return DbEntity.InDueDate;
            }
            set
            {
                DbEntity.InDueDate = DateTime.MinValue == value ? null : value;
                if (value != null && value < new DateTime(1899, 1, 1, 0, 0, 0))
                {
                    DbEntity.InDueDate = new DateTime(1899, 1, 1, 0, 0, 0);
                }
                this.SendPropertyChanged("InDueDate");
            }
        }

        public System.DateTime? InPositionDate
        {
            get
            {
                return DbEntity.InPositionDate;
            }
            set
            {
                DbEntity.InPositionDate = DateTime.MinValue == value ? null : value;
                if (value != null && value < new DateTime(1899, 1, 1, 0, 0, 0))
                {
                    DbEntity.InPositionDate = new DateTime(1899, 1, 1, 0, 0, 1);
                }
                this.SendPropertyChanged("InPositionDate");
            }
        }

        public System.Nullable<System.DateTime> ContractEndDate
        {
            get
            {
                return DbEntity.ContractEndDate;
            }
            set
            {
                DbEntity.ContractEndDate = DateTime.MinValue == value ? null : value;
                this.SendPropertyChanged("ContractEndDate");
            }
        }

        public string EmpType
        {
            get
            {
                return DbEntity.EmpType;
            }
            set
            {
                DbEntity.EmpType = value; this.SendPropertyChanged("EmpType");
            }
        }

        public string EmpStatus
        {
            get
            {
                return DbEntity.EmpStatus;
            }
            set
            {
                DbEntity.EmpStatus = value; this.SendPropertyChanged("EmpStatus");
            }
        }

        public string WorkAddress
        {
            get
            {
                return DbEntity.WorkAddress;
            }
            set
            {
                DbEntity.WorkAddress = value; this.SendPropertyChanged("WorkAddress");
            }
        }

        public System.DateTime? DimissionDate
        {
            get
            {
                return DbEntity.DimissionDate;
            }
            set
            {
                DbEntity.DimissionDate = DateTime.MinValue == value ? null : value;
                this.SendPropertyChanged("DimissionDate");
            }
        }

        public string Nationality
        {
            get
            {
                return DbEntity.Nationality;
            }
            set
            {
                DbEntity.Nationality = value; this.SendPropertyChanged("Nationality");
            }
        }

        public string BankName
        {
            get
            {
                return DbEntity.BankName;
            }
            set
            {
                DbEntity.BankName = value; this.SendPropertyChanged("BankName");
            }
        }

        public string BankAccount
        {
            get
            {
                return DbEntity.BankAccount;
            }
            set
            {
                DbEntity.BankAccount = value; this.SendPropertyChanged("BankAccount");
            }
        }

        public string SocialSecurityNo
        {
            get
            {
                return DbEntity.SocialSecurityNo;
            }
            set
            {
                DbEntity.SocialSecurityNo = value; this.SendPropertyChanged("SocialSecurityNo");
            }
        }

        public string Education
        {
            get
            {
                return DbEntity.Education;
            }
            set
            {
                DbEntity.Education = value; this.SendPropertyChanged("Education");
            }
        }

        public string School
        {
            get
            {
                return DbEntity.School;
            }
            set
            {
                DbEntity.School = value; this.SendPropertyChanged("School");
            }
        }

        public string Major
        {
            get
            {
                return DbEntity.Major;
            }
            set
            {
                DbEntity.Major = value; this.SendPropertyChanged("Major");
            }
        }

        public string NativePlace
        {
            get
            {
                return DbEntity.NativePlace;
            }
            set
            {
                DbEntity.NativePlace = value; this.SendPropertyChanged("NativePlace");
            }
        }

        public string RelationName
        {
            get
            {
                return DbEntity.RelationName;
            }
            set
            {
                DbEntity.RelationName = value; this.SendPropertyChanged("RelationName");
            }
        }

        public string RelationTel
        {
            get
            {
                return DbEntity.RelationTel;
            }
            set
            {
                DbEntity.RelationTel = value; this.SendPropertyChanged("RelationTel");
            }
        }

        public short FlagDeleted
        {
            get
            {
                return DbEntity.FlagDeleted;
            }
            set
            {
                DbEntity.FlagDeleted = value; this.SendPropertyChanged("FlagDeleted");
            }
        }

        public System.DateTime? ModDate
        {
            get
            {
                return DbEntity.ModDate;
            }
            set
            {
                DbEntity.ModDate = DateTime.MinValue == value ? null : value;
                this.SendPropertyChanged("ModDate");
            }
        }

        public short? ProbationTerm
        {
            get
            {
                return DbEntity.ProbationTerm;
            }
            set
            {
                DbEntity.ProbationTerm = value; this.SendPropertyChanged("ProbationTerm");
            }
        }

        public System.DateTime SyncTime
        {
            get
            {
                return DbEntity.SyncTime;
            }
            set
            {
                DbEntity.SyncTime = value; this.SendPropertyChanged("SyncTime");
            }
        }

        public string DeptID
        {
            get { return DbEntity.DeptID; }
            set { DbEntity.DeptID = value; this.SendPropertyChanged("DeptID"); }
        }

        private string _PositionID;
        public string PositionID
        {
            get { return _PositionID; }
            set { _PositionID = value; this.SendPropertyChanged("PositionID"); }
        }
        private string _PositionName;
        public string PositionName
        {
            get { return _PositionName; }
            set { _PositionName = value; this.SendPropertyChanged("PositionName"); }
        }
        //private string _DeptID;
        //public string DeptID
        //{
        //    get { return _DeptID; }
        //    set { _DeptID = value; this.SendPropertyChanged("DeptID"); }
        //}
        private string _DeptName;
        public string DeptName
        {
            get { return _DeptName; }
            set { _DeptName = value; this.SendPropertyChanged("DeptName"); }
        }
        private string _DeptFullName;
        public string DeptFullName
        {
            get { return _DeptFullName; }
            set { _DeptFullName = value; this.SendPropertyChanged("DeptFullName"); }
        }
        private string _DeptPath;
        public string DeptPath
        {
            get
            {
                return _DeptPath;
            }
            set
            {
                _DeptPath = value; this.SendPropertyChanged("DeptPath");
            }
        }
        private string _RoleID;
        public string RoleID
        {
            get
            {
                return _RoleID;
            }
            set
            {
                _RoleID = value; this.SendPropertyChanged("RoleID");
            }
        }
        private string _JobID;
        public string JobID
        {
            get
            {
                return _JobID;
            }
            set
            {
                _JobID = value; this.SendPropertyChanged("JobID");
            }
        }
        private string _JobName;
        public string JobName
        {
            get { return _JobName; }
            set { _JobName = value; this.SendPropertyChanged("JobName"); }
        }

        private int _SeqNo;
        public int SeqNo
        {
            get { return _SeqNo; }
            set { _SeqNo = value; }
        }
        #endregion

        /// <summary>
        /// 从数据库对象创建逻辑对象
        /// </summary>
        /// <param name="employee">数据库对象</param>
        /// <returns>逻辑对象</returns>
        [Obsolete("请使用 new EmployeeEntity(employee) ")]
        public static EmployeeEntity CreateEntityFromDb(Employee employee)
        {
            if (null == employee) return null;
            EmployeeEntity ret = new EmployeeEntity(employee);
            return ret;
        }
    }
}
